package com.music.activity;

import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;

import com.music.R;
import com.music.utilbean.AndroidShare;
import com.music.utilbean.KuwoApplication;


@SuppressLint("NewApi")
public class Tab2ActivityMusic extends MusicBaseActivity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab2);
	}

	public void sharemusic(String id) {
		AndroidShare as = new AndroidShare(
				Tab2ActivityMusic.this,
				Tab1ActivityMusic.user,
				//"http://img6.cache.netease.com/cnews/news2012/img/logo_news.png"
				id);
		as.show();
	}

	@Override
	public void publish(int progress) {
		// 更新进度

	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();

	}

	@SuppressLint("NewApi")
	@Override
	public void change(int position) {
		// 切换播放位置	
		musicListFragment = (MyMusicListFragment) getFragmentManager().findFragmentById(R.id.fragment);
		musicListFragment.changeUIstateOnplay(position);//需要得到fragment实例对象
		Log.e("Tab2ActivityMusic", "change: " + position);
	}

	@Override
	protected void onDestroy() {
		//activity销毁时
		super.onDestroy();
		//保存当前播放的一些状态值
		KuwoApplication application = (KuwoApplication) getApplication();
		SharedPreferences.Editor editor = application.sharedPreferences.edit();
		editor.putInt("currentposition", playService.getCurrentPosition());
		editor.putInt("play_mode", playService.getPlay_mode());
		editor.apply();
	}
}
